<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>权限列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="{{asset('layui/css/layui.css')}}" media="all">
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <script type="text/javascript" src="{{asset('Jquery/jquery-3.3.1.js')}}"></script>
    <script src="{{asset('layui/layui.js')}}"></script>
</head>

<body>
<style>
    #item th{
        color:black;
        text-align: center;
    }
    #content th{
        color:#666666;
        text-align: center;
    }
</style>
<div class="layui-form" id="movieList">
    <form action="{{url('permissionList')}}" method="get" id="data">
        <table class="layui-table">
            <thead>
            <tr>
                <th colspan="12" style="color:#666666;font-size: 18px;text-align: center">权限列表</th>
            </tr>
            <tr>
                <th colspan="12">
                    <div id="input" class="layui-inline">
                        <input type="text"  placeholder="请输入权限名进行搜索" class="layui-input" name="name" style="width: 200px"/>
                    </div>
                    {{--<div id="input" class="layui-inline">
                        <input type="text"  placeholder="请输入拆迁公司进行搜素" class="layui-input" name="actuator" style="width: 200px"/>
                    </div>--}}
                    {{-- <div class="layui-inline">
                         <select name="project_leader" lay-filter="select" id="type">
                             <option value="">请选择项目负责人</option>
                             @foreach($allProject as $project)
                                 <option value="{{$project->project_leader}}">{{$project->project_leader}}</option>
                             @endforeach

                         </select>
                     </div>--}}
                    {{-- <div class="layui-inline">
                         <select name="status"  lay-filter="select" id="year">
                             <option value="">请选择项目进度</option>
                                 <option value="1">前期调查中</option>
                                 <option value="2">合同签订中</option>
                                 <option value="3">审计中</option>
                                 <option value="4">支付中</option>
                                 <option value="5">已完成</option>
                         </select>
                     </div>--}}
                    {{--<div class="layui-inline">
                        <select name="type" lay-filter="select" id="type">
                            <option value="">请选择区域</option>
                            <option value="剧情">家庭</option>
                            <option value="喜剧">喜剧</option>
                            <option value="动作">动作</option>
                            <option value="言情">言情</option>

                        </select>
                    </div>--}}


                    {{--  <div class="layui-inline">
                          <select name="start_end_time"  lay-filter="select" id="year">
                              <option value="">请选择日期</option>
                              @foreach($allProject as $project)
                                  <option value="{{$project->start_end_time}}">{{$project->start_end_time}}</option>
                              @endforeach

                          </select>
                      </div>--}}



                    <div class="layui-inline">
                        <button class="layui-btn  layui-btn-radius " id="search"><i class="layui-icon layui-icon-search" style="font-size: 15px; color:black;"></i><b style="color:white">搜索</b></button>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-primary layui-btn-radius layui-btn-warm" id="reset"><i class="layui-icon layui-icon-set-fill" style="font-size: 15px; color:dodgerblue;"></i><b style="color:white">重置</b></button>
                    </div>
                    <div class="layui-inline">
                        <input type="hidden" name="video_type" value="1">
                    </div>
                </th>
            </tr>
            </thead>
        </table>
    </form>

    <div class="add">
        <table class="layui-table">
            <thead>
            <tr>
                <th>
                    <button class="layui-btn layui-btn-sm  layui-btn-radius layui-btn-normal" id="newProject"><i class="layui-icon">&#xe654;</i>添加权限</button>
                </th>
            </tr>
            </thead>
        </table>

    </div>

    <div  class="oldData" id="oldData">
        <table class="layui-table">
            <thead>
            <tr id="item">
                <th><button class="layui-btn layui-btn-xs ">ID</button></th>
                <th><button class="layui-btn layui-btn-xs ">权限名</button></th>
                <th><button class="layui-btn layui-btn-xs ">路由</button></th>
                <th><button class="layui-btn layui-btn-xs ">权限描述</button></th>
                <th colspan="2"><button class="layui-btn layui-btn-xs layui-bg-orange">操作</button></th>
            </tr>
            </thead>
            <tbody>

              @foreach($allPermission as $k=>$permission)
                <tr id="content">
                    <th><button class="layui-btn layui-btn-xs layui-bg-cyan">{{$permission->id}}</button></th>
                    <th>{{$permission->name}}</th>
                    <th>{{$permission->route}}</th>
                    <th>{{$permission->description}}</th>
                    <th class="edit"><button class="layui-btn layui-btn-sm layui-btn-radius layui-btn-normal"><i class="layui-icon"></i>编辑</button></th>
                    <input type="hidden"  value="{{$permission->id}}">
                    <th class="delete"><button class="layui-btn layui-btn-sm layui-btn-radius layui-btn-danger"><i class="layui-icon"></i>删除</button></th>
                    <input type="hidden"  value="{{$permission->id}}">
                </tr>

             @endforeach
            <tr><th colspan="8" style="text-align: center;color: darkorange" >{{$allPermission->links()}}</th></tr>
            </tbody>
        </table>

    </div>
</div>
</body>
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        //日期范围
        laydate.render({
            elem: '#test6'
            ,range: true
        });
    })
</script>
<script>
    layui.use('form', function () {
        var form = layui.form;
    });
</script>
{{--点击查看电影详情--}}
<script type="text/javascript">
    $(function(){
        $(".xiangqing").click(function(){
            var videoID=$(this).next().val();
            layui.use('layer', function(){
                var layer = layui.layer;
                layer.open({
                    type: 2,
                    title: ['电影详情', 'font-size:18px;color:green;'],
                    area: ['1200px', '800px'],
                    content:"{{url('videoDetail/videoID=')}}"+videoID ,//这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
                });
            });

        });



    });
</script>
{{--点击设置修改--}}
<script>
    $(function () {
        layui.use('form', function() {
            var form = layui.form
                , layer = layui.layer;


            /*监听是否上下映*/
            form.on('switch(switchIsSale)', function(data){
                var change = data.elem.checked;//开关是否开启，true或者false
                var video_id=$(this).val();
                if(change){
                    var  is_sale=1;
                    var url="{{url('movieIsSale')}}";
                    $.ajax({
                        url:url,
                        type:'POST',
                        dataType:'json',
                        data:{'video_id':video_id,'is_sale':is_sale,'_token':"{{csrf_token()}}"},
                        success:function(response){
                            if(response.msg==200){
                                layer.msg('小主，电影已上映！', {icon: 6});
                            }
                        }
                    });
                }else{
                    var is_sale=0;
                    var url="{{url('movieIsSale')}}";
                    $.ajax({
                        url:url,
                        type:'POST',
                        dataType:'json',
                        data:{'video_id':video_id,'is_sale':is_sale,'_token':"{{csrf_token()}}"},
                        success:function(response){
                            if(response.msg==200){
                                layer.msg('小主，电影已下映！', {icon: 6});
                            }
                        }
                    });
                }
            });


            /*监听是否设为精选*/
            form.on('switch(switchIsJingXuan)', function(data){
                var change = data.elem.checked;//开关是否开启，true或者false
                var video_id=$(this).val();
                var url="{{url('movieIsJingXuan')}}";
                if(change){
                    var  is_jingxuan=1;
                    $.ajax({
                        url:url,
                        type:'POST',
                        dataType:'json',
                        data:{'video_id':video_id,'is_jingxuan':is_jingxuan,'_token':"{{csrf_token()}}"},
                        success:function(response){
                            if(response.msg==200){
                                layer.msg('小主，电影已设为精选！', {icon: 6});
                            }
                        }
                    });
                }else{
                    var is_jingxuan=0;
                    $.ajax({
                        url:url,
                        type:'POST',
                        dataType:'json',
                        data:{'video_id':video_id,'is_jingxuan':is_jingxuan,'_token':"{{csrf_token()}}"},
                        success:function(response){
                            if(response.msg==200){
                                layer.msg('小主，电影已取消精选！', {icon: 6});
                            }
                        }
                    });
                }
            });


            /*监听是否设为轮播*/
            form.on('switch(switchIsLunbo)', function(data){
                var change = data.elem.checked;//开关是否开启，true或者false
                var video_id=$(this).val();
                var url="{{url('movieIsLunBo')}}";
                if(change){
                    var  is_lunbo=1;
                    $.ajax({
                        url:url,
                        type:'POST',
                        dataType:'json',
                        data:{'video_id':video_id,'is_lunbo':is_lunbo,'_token':"{{csrf_token()}}"},
                        success:function(response){
                            if(response.msg==200){
                                layer.msg('小主，电影已设为轮播！', {icon: 6});
                            }
                        }
                    });
                }else{
                    var is_lunbo=0;
                    $.ajax({
                        url:url,
                        type:'POST',
                        dataType:'json',
                        data:{'video_id':video_id,'is_lunbo':is_lunbo,'_token':"{{csrf_token()}}"},
                        success:function(response){
                            if(response.msg==200){
                                layer.msg('小主，电影已取消轮播！', {icon: 6});
                            }
                        }
                    });
                }
            });

            /*监听是否设为热播*/
            form.on('switch(switchIsHot)', function(data){
                var change = data.elem.checked;//开关是否开启，true或者false
                var video_id=$(this).val();
                var url="{{url('movieIsHot')}}";
                if(change){
                    var  is_hot=1;
                    $.ajax({
                        url:url,
                        type:'POST',
                        dataType:'json',
                        data:{'video_id':video_id,'is_hot':is_hot,'_token':"{{csrf_token()}}"},
                        success:function(response){
                            if(response.msg==200){
                                layer.msg('小主，电影已设为热播！', {icon: 6});
                            }
                        }
                    });
                }else{
                    var is_hot=0;
                    $.ajax({
                        url:url,
                        type:'POST',
                        dataType:'json',
                        data:{'video_id':video_id,'is_hot':is_hot,'_token':"{{csrf_token()}}"},
                        success:function(response){
                            if(response.msg==200){
                                layer.msg('小主，电影已取消热播！', {icon: 6});
                            }
                        }
                    });
                }
            });


            /*监听是否设为分享*/
            form.on('switch(switchShareWatch)', function(data){
                var change = data.elem.checked;//开关是否开启，true或者false
                var video_id=$(this).val();
                var url="{{url('movieIsShare')}}";
                if(change){
                    var  share_watch=1;
                    $.ajax({
                        url:url,
                        type:'POST',
                        dataType:'json',
                        data:{'video_id':video_id,'share_watch':share_watch,'_token':"{{csrf_token()}}"},
                        success:function(response){
                            if(response.msg==200){
                                layer.msg('小主，电影已设为分享观看！', {icon: 6});
                            }
                        }
                    });
                }else{
                    var share_watch=0;
                    $.ajax({
                        url:url,
                        type:'POST',
                        dataType:'json',
                        data:{'video_id':video_id,'share_watch':share_watch,'_token':"{{csrf_token()}}"},
                        success:function(response){
                            if(response.msg==200){
                                layer.msg('小主，电影已取消分享观看！', {icon: 6});
                            }
                        }
                    });
                }
            });


        });
    });
</script>
{{--点击删除电影--}}
<script>
    $(function(){
        $(".delete").click(function(){
            var permissionId=$(this).next().val();
            var url="{{url('deletePermission')}}";
            $.ajax({
                url:url,
                type:'POST',
                dataType:'json',
                data:{'permissionId':permissionId,'_token':"{{csrf_token()}}"},
                success:function(response){
                    if(response.msg==200){
                        layer.msg('小主，删除成功！', {icon: 6});
                        setTimeout("window.location.reload();",1000);


                    }


                }
            });
        });


    });
</script>
{{--根据条件查询相关的电影数据--}}
<script>
    $(function(){
        $("#search").click(function(){
            $("#data").submit();
        });
        $("#reset").click(function(){
            window.location.href="{{url('rolePermission')}}";
        });
    });
</script>

{{--点击新建调查--}}
<script type="text/javascript">
    $(function(){
        $("#newProject").click(function(){
            layui.use('layer', function(){
                var layer = layui.layer;
                layer.open({
                    type: 2,
                    title: ['添加权限', 'font-size:18px;color:green;'],
                    area: ['600px', '400px'],
                    content:"{{url('createPermission')}}" ,//这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
                });
            });

        });
    });
</script>
{{--点击编辑调查--}}
<script type="text/javascript">
    $(function(){
        $(".edit").click(function(){
            var permissionId=$(this).next().val();
            layui.use('layer', function(){
                var layer = layui.layer;
                layer.open({
                    type: 2,
                    title: ['编辑权限', 'font-size:18px;color:green;'],
                    area: ['600px', '400px'],
                    content:"{{url('editPermission/permissionId=')}}"+permissionId//这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
                });
            });

        });



    });
</script>

</html>